#pragma once

#include "tinyxml.h"
#include <list>

namespace Core
{
	class NScope;
	class NDatum;
}

namespace NXML
{

class NXmlParseHelper;
class NXmlParseMaster
{

public:
	struct NXmlSharedData
	{
		NXmlSharedData()
			:DepthCounter(0),
			 XmlMaster(NULL),
			 SkipContainedData(false)
		{}

		unsigned int DepthCounter;
		NXmlParseMaster* XmlMaster;

		Core::NScope* CurrentScope;
		Core::NDatum* CurrentDatum;
		bool SkipContainedData;
	};

public:
	NXmlParseMaster(void);

	virtual ~NXmlParseMaster(void);

	static void Initialize();

	static void Deinitialize();

	static NXmlParseMaster* GetInstance();

	void AddHelper(NXmlParseHelper* aHelper);

	void RemoveHelper(NXmlParseHelper* aHelper);

	void ParseXMl(const char* file);

	NXmlParseMaster::NXmlSharedData * NXmlParseMaster::GetSharedData();

private:
	void StartElementParse(TiXmlElement* element);

	void BeginParse(const char* file);

private:
	static NXmlParseMaster* sInstance;
	std::list<NXmlParseHelper*> mHealpers;		//!<< list of helpers
	NXmlSharedData mSharedData;

	
};

}